## innovus 18.15

set path /projects/cascade/workspace/xwqiu/RDL/innovus.20251106

source ${path}/RDL_Routing/proc_RDL.tcl
set wire(AP,width,in) 28
set wire(AP,width,out) 22

proc pr_draw_AP_out_H {} {
	global wire
	set bumps [dbget selected]
	foreach bump ${bumps} {
		set bump_name [dbget $bump.net.name]
		set bump_box_llx [dbget $bump.bump_shape_bbox_llx]
		set bump_box_lly [dbget $bump.bump_shape_bbox_lly]
		set bump_box_urx [dbget $bump.bump_shape_bbox_urx]
		set bump_box_ury [dbget $bump.bump_shape_bbox_ury]
		set bump_box_centerx [dbget $bump.bump_shape_center_x]
		set bump_box_centery [dbget $bump.bump_shape_center_y]

		## top
		set top_start_x [expr ${bump_box_llx}-3-$wire(AP,width,out)/2-20]
		set top_end_x   [expr ${bump_box_urx}+3+$wire(AP,width,out)/2+20]
		set top_y       [expr ${bump_box_ury}+3+$wire(AP,width,out)/2]
		set pt_list {}
		set pt_start "${top_start_x} ${top_y}"
		set pt_end "${top_end_x} ${top_y}"

		lappend pt_list $pt_start $pt_end
		puts $pt_list

		pr_auto_edit_wire AP $bump_name $wire(AP,width,out) $pt_list

		## bottom
		set bottom_start_x [expr ${bump_box_llx}-3-$wire(AP,width,out)/2-20]
		set bottom_end_x   [expr ${bump_box_urx}+3+$wire(AP,width,out)/2+20]
		set bottom_y       [expr ${bump_box_lly}-3-$wire(AP,width,out)/2]
		set pt_list {}
		set pt_start "${bottom_start_x} ${bottom_y}"
		set pt_end "${bottom_end_x} ${bottom_y}"

		lappend pt_list $pt_start $pt_end
		puts $pt_list
		pr_auto_edit_wire AP $bump_name $wire(AP,width,out) $pt_list
	}

}

proc pr_draw_AP_out_V {} {
	global wire
	set bumps [dbget selected]
	foreach bump ${bumps} {
		set bump_name [dbget $bump.net.name]
		set bump_box_llx [dbget $bump.bump_shape_bbox_llx]
		set bump_box_lly [dbget $bump.bump_shape_bbox_lly]
		set bump_box_urx [dbget $bump.bump_shape_bbox_urx]
		set bump_box_ury [dbget $bump.bump_shape_bbox_ury]
		set bump_box_centerx [dbget $bump.bump_shape_center_x]
		set bump_box_centery [dbget $bump.bump_shape_center_y]


		## left
		set left_start_y [expr ${bump_box_lly}-3-$wire(AP,width,out)/2]
		set left_end_y   [expr ${bump_box_ury}+3+$wire(AP,width,out)/2]
		set left_x       [expr ${bump_box_llx}-3-$wire(AP,width,out)/2]
		set pt_list {}
		set pt_start "${left_x} ${left_start_y}"
		set pt_end "${left_x} ${left_end_y}"

		lappend pt_list $pt_start $pt_end
		puts $pt_list
		pr_auto_edit_wire AP $bump_name $wire(AP,width,out) $pt_list

		## right
		set right_start_y [expr ${bump_box_lly}-3-$wire(AP,width,out)/2]
		set right_end_y   [expr ${bump_box_ury}+3+$wire(AP,width,out)/2]
		set right_x       [expr ${bump_box_urx}+3+$wire(AP,width,out)/2]
		set pt_list {}
		set pt_start "${right_x} ${right_start_y}"
		set pt_end "${right_x} ${right_end_y}"

		lappend pt_list $pt_start $pt_end
		puts $pt_list
		pr_auto_edit_wire AP $bump_name $wire(AP,width,out) $pt_list
	}
}

proc pr_draw_AP_in {} {
	global wire
	set bumps [dbget selected]
	foreach bump ${bumps} {
		set bump_name [dbget $bump.net.name]
		set bump_box_llx [dbget $bump.bump_shape_bbox_llx]
		set bump_box_lly [dbget $bump.bump_shape_bbox_lly]
		set bump_box_urx [dbget $bump.bump_shape_bbox_urx]
		set bump_box_ury [dbget $bump.bump_shape_bbox_ury]
		set bump_box_centerx [dbget $bump.bump_shape_center_x]
		set bump_box_centery [dbget $bump.bump_shape_center_y]

		set H_start [expr ${bump_box_llx}-3-$wire(AP,width,out)/2-20]
		set H_end   [expr ${bump_box_urx}+3+$wire(AP,width,out)/2+20]
		set V_start [expr ${bump_box_lly}-3-$wire(AP,width,out)/2]
		set V_end   [expr ${bump_box_ury}+3+$wire(AP,width,out)/2]

		set pt_list {}
		set pt_start "${H_start} ${bump_box_centery}"
		set pt_end   "${H_end}   ${bump_box_centery}"
		lappend pt_list $pt_start $pt_end
		puts $pt_list
		pr_auto_edit_wire AP $bump_name $wire(AP,width,in) $pt_list

		set pt_list {}
		set pt_start "${bump_box_centerx} ${V_start}"
		set pt_end   "${bump_box_centerx} ${V_end}"
		lappend pt_list $pt_start $pt_end
		puts $pt_list
		pr_auto_edit_wire AP $bump_name $wire(AP,width,in) $pt_list
	}
}

proc pr_draw_AP_H_out_PHY {} {
	global wire
	set bumps [dbget selected]
	foreach bump ${bumps} {
		set bump_name [dbget $bump.net.name]
		set bump_box_llx [dbget $bump.bump_shape_bbox_llx]
		set bump_box_lly [dbget $bump.bump_shape_bbox_lly]
		set bump_box_urx [dbget $bump.bump_shape_bbox_urx]
		set bump_box_ury [dbget $bump.bump_shape_bbox_ury]
		set bump_box_centerx [dbget $bump.bump_shape_center_x]
		set bump_box_centery [dbget $bump.bump_shape_center_y]

		## top
		set top_start_x [expr ${bump_box_llx}-3-$wire(AP,width,out)]
		set top_end_x   [expr ${bump_box_urx}+3+$wire(AP,width,out)]
		set top_y       [expr ${bump_box_ury}+3+$wire(AP,width,out)/2]
		set pt_list {}
		set pt_start "${top_start_x} ${top_y}"
		set pt_end "${top_end_x} ${top_y}"

		lappend pt_list $pt_start $pt_end
		puts $pt_list

		pr_auto_edit_wire AP $bump_name $wire(AP,width,out) $pt_list

		## bottom
		set bottom_start_x [expr ${bump_box_llx}-3-$wire(AP,width,out)]
		set bottom_end_x   [expr ${bump_box_urx}+3+$wire(AP,width,out)]
		set bottom_y       [expr ${bump_box_lly}-3-$wire(AP,width,out)/2]
		set pt_list {}
		set pt_start "${bottom_start_x} ${bottom_y}"
		set pt_end "${bottom_end_x} ${bottom_y}"

		lappend pt_list $pt_start $pt_end
		puts $pt_list
		pr_auto_edit_wire AP $bump_name $wire(AP,width,out) $pt_list
	}
}

proc pr_draw_AP_in_PHY {} {
	global wire
	set bumps [dbget selected]
	foreach bump ${bumps} {
		set bump_name [dbget $bump.net.name]
		set bump_box_llx [dbget $bump.bump_shape_bbox_llx]
		set bump_box_lly [dbget $bump.bump_shape_bbox_lly]
		set bump_box_urx [dbget $bump.bump_shape_bbox_urx]
		set bump_box_ury [dbget $bump.bump_shape_bbox_ury]
		set bump_box_centerx [dbget $bump.bump_shape_center_x]
		set bump_box_centery [dbget $bump.bump_shape_center_y]

		set H_start [expr ${bump_box_llx}-3-$wire(AP,width,out)]
		set H_end   [expr ${bump_box_urx}+3+$wire(AP,width,out)]
		set V_start [expr ${bump_box_lly}-3-$wire(AP,width,out)/2]
		set V_end   [expr ${bump_box_ury}+3+$wire(AP,width,out)/2]

		set pt_list {}
		set pt_start "${H_start} ${bump_box_centery}"
		set pt_end   "${H_end}   ${bump_box_centery}"
		lappend pt_list $pt_start $pt_end
		puts $pt_list
		pr_auto_edit_wire AP $bump_name $wire(AP,width,in) $pt_list

		set pt_list {}
		set pt_start "${bump_box_centerx} ${V_start}"
		set pt_end   "${bump_box_centerx} ${V_end}"
		lappend pt_list $pt_start $pt_end
		puts $pt_list
		pr_auto_edit_wire AP $bump_name $wire(AP,width,in) $pt_list
	}
}

proc pr_draw_bump {} {
	pr_draw_AP_out_V
	pr_draw_AP_out_H
	pr_draw_AP_in
}

proc pr_draw_bump_PHY {} {
	pr_draw_AP_out_V
	pr_draw_AP_H_out_PHY
	pr_draw_AP_in_PHY
}